#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: DDLbase.py 
@version:
@time: 2022/01/13 
"""
import os

from TapUtil.operatefile.use_json import read_json
from TapUtil.operatefile.use_yaml import read_yaml

__all__ = ['DDL_YML_STRING']

DML_ROOT_PATH = os.path.dirname(os.path.realpath(__file__))

# MODULE_LIST = ['01TapMysql', '02TapOracle', '03TapMongoDB', '04TapDB2', '05TapPostgres',
#                '06TapSqlserver', '07TapGbase', '08TapSybase', '09TapGaussDB', '10TapES',
#                '11TapRedis', '12TapKafka', '13TapMariaDB', '14TapMysqlPXC', '15TapDM', '16TapHive',
#                '17TapTCP_IP', '18TapMQ', '19TapHBase', '20TapKudu', '21TapGreenplum', '22TapTiDB',
#                '23TapHANA', '24TapClickHouse', '25TapKunDB', '26TapADBpostgres', '27TapADBmysql',
#                '28TapVika', 'OTHER01TapGridFS', 'OTHER02TapFiles', 'OTHER03TapDummyDB',
#                'OTHER04TapCustomConnection'
#                ]
MODULE_DICT = {
    'common': '00COMMON',
    'mysql': '01TapMysql', 'oracle': '02TapOracle', 'mongodb': '03TapMongoDB', 'db2': '04TapDB2',
    'postgres': '05TapPostgres', 'sqlserver': '06TapSqlserver', 'gbase-8s': '07TapGbase',
    'sybase ase': '08TapSybase',
    'gaussdb200': '09TapGaussDB', 'elasticsearch': '10TapES', 'redis': '11TapRedis', 'kafka': '12TapKafka',
    'mariadb': '13TapMariaDB',
    'mysql pxc': '14TapMysqlPXC', 'dameng': '15TapDM', 'hive': '16TapHive', 'tcp_udp': '17TapTCP_IP',
    'mq': '18TapMQ',
    'hbase': '19TapHBase', 'kudu': '20TapKudu', 'greenplum': '21TapGreenplum', 'tidb': '22TapTiDB',
    'hana': '23TapHANA',
    'clickhouse': '24TapClickHouse', 'kundb': '25TapKunDB', 'adb_postgres': '26TapADBpostgres',
    'adb_mysql': '27TapADBmysql',
    'vika': '28TapVika', 'GridFS': 'OTHER01TapGridFS', 'Files': 'OTHER02TapFiles',
    'DummyDB': 'OTHER03TapDummyDB', 'CustomConnection': 'OTHER04TapCustomConnection'}


def DDL_YML_STRING(kwargs):
    dbtype = kwargs.get('DBTYPE')
    ddltype = kwargs.get('FILE')
    return read_yaml(f'{DML_ROOT_PATH}/DDL{MODULE_DICT.get(dbtype)}/{ddltype}.yml')
